﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Incubator.Controls
{
    public partial class CreateCompany : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null || (int)Session["UserID"] == -1)
                Response.Redirect("main.aspx");
        }

        protected void createButton_Click(object sender, EventArgs e)
        {

           int user_id = -1;
            int init_money = 100000;

            if ((user_id = (int)Session["UserID"]) > 0)
            {
               Global.incuServ.CreateCompany(CompanyNameTB.Text, DescriptionTB.Text, init_money,(Incubator.webRef.User)Session["User"]);
                warningMessage.Text = "Company has been created successful!";
                Session["User"] = Global.incuServ.GetUser((int)Session["UserId"]);
                Response.Redirect("Company.aspx");
            }
            else
            {
                warningMessage.Text = "Please Log In first!";
            }
        }
    }
}